<template>
	<view class="wp">
		<view class="fill_bg">
			<image class="bg" src="https://img.jinghushi.com/images/9/2024/07/gJqlQNlAjD7Lj75X0nA2lv3YXlZM3k.png" mode="widthFix"></image>
		</view>
		<view class="content">
			<view class="list">
				<view class="item" v-for="item in vipGoodsList" @click="$navTo('/pages/product/groupbuy?id='+item.id+'&isVip=1')">
					<view class="l_title">{{item.title}}</view>
					<view class="pics">
						<image :src="items" v-for="(items,index) in item.pics"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="xieyi">开通前请阅读<text @click="$navTo('https://bpapi.jinghushi.com/vip.html')">《VIP服务协议》</text></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: [],
				vipGoodsList: [],
				vipCurr: 0,
				mid: -1
			}
		},
		async onLoad(options) {
			if(options.mid){
				this.mid = options.mid;
			}
			// this.getUserInfo();
			this.getVipGoodsList();
			// await this.$onLaunched;
			if(!uni.getStorageSync('token')){
				this.getToken();
			}
		},
		methods: {
			getToken(){
				uni.login({
					provider: 'weixin',
					success:res=> {
						this.$axios('login/autologin','POST','member',{
							aid: uni.getStorageSync('appid').slice(-4),
							mid: this.mid,
							code: res.code
						}).then(res=>{
							if(res.data.code == 200){
								uni.setStorageSync('token', res.data.data);
								uni.setStorageSync('Jh_recotabshops', 1);
								this.getSharePath();
							}
						})
					}
				})
			},
			preview(index){
				uni.previewImage({
					urls: this.vipGoodsList[this.vipCurr].pics,
					current: index
				})
			},
			changeVip(id){
				this.vipCurr = id;
			},
			toBuyReal(){
				if (!uni.getStorageSync('token')) {
					this.$refs.popup.open();
					return;
				}
				uni.navigateTo({
					url: '/pages/order/createOrder?type=3&id='+this.vipGoodsList[this.vipCurr].id+'&optionid=0&total=1&isVip=1'
				})
			},
			getUserInfo(){
				this.$axios('Center/main','POST','member').then(res=>{
					if(res.data.code == 200){
						this.userInfo = res.data.data;
					}
				})
			},
			getVipGoodsList(){
				this.$axios('home/vipgoodslist','POST','shop').then(res=>{
					if(res.data.code == 200){
						this.vipGoodsList = res.data.data.list;
					}
				})
			},
			navto(url) {
				if (url != "#" && url != "") {
					if (url.indexOf('http') == -1) {
						uni.navigateTo({
							url: url
						})
					} else {
						// #ifdef APP-PLUS || MP-WEIXIN
						uni.navigateTo({
							url: "../web/web-view?url=" + url
						})
						// #endif
						// #ifdef H5
						window.location.href = url
						// #endif
					}
				}
			},
		}
	}
</script>

<style lang="scss">
	.wp {
		background: #1c1817;
		padding-bottom: 40rpx;
	}
	.fill_bg{
		// position: relative;
		.bg{
			width: 100%;
		}
	}
	.content{
		padding: 0 60rpx 40rpx;
		margin-top: -20rpx;
		.list{
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.item{
				margin-bottom: 26rpx;
				overflow: hidden;
				width: 100%;
				background: #202020;
				box-shadow: 0rpx 0rpx 16rpx 12rpx rgba(0,0,0,0.5);
				border-radius: 26rpx;
				text-align: center;
				padding: 30rpx;
				.l_title{
					font-weight: 600;
					font-size: 36rpx;
					color: #FFE6B7;
					margin-bottom: 24rpx;
				}
				.pics{
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;
					image{
						width: 271rpx;
						height: 200rpx;
						display: block;
						border-radius: 20rpx;
						margin-bottom: 20rpx;
					}
				}
			}
		}
	}

.xieyi{
	// background: #fbf8fe;
	color: #999;
	font-size: 24rpx;
	padding: 20rpx;
	text{
		// color: $bg-color;
		color: #d5b28f;
	}
}
</style>